package com.palfund.nested;

import android.support.v4.view.PagerAdapter;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import java.util.ArrayList;

/**
 * Created by clvc on 2017/10/31.
 * 真正的速度是看不见的 !
 * Today is today , we will go !
 */

public class VPAdapter extends PagerAdapter {
    private ArrayList<ImageView> mList;

    public VPAdapter(ArrayList<ImageView> list) {
        mList = list;
    }

    @Override
    public int getCount() {
        return mList.size();
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        Log.i("VPAdapter", "---instantiateItem()--->" + position);
        ImageView imageView = mList.get(position);
        container.addView(imageView);
        return imageView;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        Log.i("VPAdapter", "---destroyItem()--->" + position);
        container.removeView((View) object);
    }
}
